package fag.core.game.test.asteroids;

import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;

import javax.imageio.ImageIO;

import fag.core.geometry.Polygon2D;
import fag.core.geometry.Vector2D;
import fag.core.model.Animation;
import fag.core.model.Frame;
import fag.core.model.Model;
import fag.core.model.SerializableImage;
import fag.core.model.Sprite;

@SuppressWarnings("serial")
public class VaisseauModel extends Model {
	
	public VaisseauModel() {
		
		BufferedImage bi = null;
		try {
			bi = ImageIO.read(new File(System.getProperty("user.dir") + "/src/imgs/asteroids/vaisseau.png"));
		} catch (IOException e) {
			e.printStackTrace();
		}
		
		Frame f = new Frame();
		f.setSprite(new Sprite(new SerializableImage(bi), new Vector2D()));
		ArrayList<Vector2D> vertices = new ArrayList<Vector2D>();
		vertices.add(new Vector2D(0, f.getSprite().getHeight()));
		vertices.add(new Vector2D(f.getSprite().getWidth() / 2, 0));
		vertices.add(new Vector2D(f.getSprite().getWidth(), f.getSprite().getHeight()));
		f.setHitbox(new Polygon2D(vertices));
		f.updateBounds();
		
		Animation a = new Animation("vaisseau");
		a.addFrame(f);
		getListAnimation().add(a);
	}
}